﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using r4u.business.logic.layer.RECRUIT;
using r4u.data.access.layer;

namespace r4u.Controllers
{
    public class SkillController : Controller
    {
        [HttpPost]
        public ActionResult Create(VACANCY_SKILL skill)
        {
            Skill temp = new Skill();

            if (temp.Insert(skill))
            {
                return new HttpStatusCodeResult(HttpStatusCode.OK);
            }
            else
            {
                return new HttpStatusCodeResult(HttpStatusCode.InternalServerError);
            }
        }


        public ActionResult Delete(int id, string id2)
        {
            Skill temp = new Skill();

            if (temp.Delete(id.ToString(), id2.ToString()))
            {
                return new HttpStatusCodeResult(HttpStatusCode.OK);
            }
            else
            {
                return new HttpStatusCodeResult(HttpStatusCode.InternalServerError);
            }
        }


        public ActionResult List(int id)
        {
            Skill temp = new Skill();
            var settings = new JsonSerializerSettings
            {
                ContractResolver = new CamelCasePropertyNamesContractResolver()
            };

            var jsonResult = new ContentResult
            {
                Content = JsonConvert.SerializeObject(temp.List(id.ToString()), settings),
                ContentType = "application/json"
            };
            return jsonResult;
        }

    }

}

